﻿using Newtonsoft.Json;
using System.Collections.Generic;

namespace Neudesic.Pulse.Entities
{

    /// <summary>
    /// Generalized entity object that represents an identity, such as person, page, or system.
    /// </summary>
    [JsonObject(MemberSerialization.OptIn)]
    public partial class Entity
    {

        [JsonProperty("cell")]
        public string Cell { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }

        [JsonProperty("emailAddress")]
        public string EmailAddress { get; set; }

        private Entity feed;

        [JsonProperty("feed")]
        public Entity Feed
        {
            get
            {
                if (feed == null && Feeds != null && Feeds.Count == 1)
                    return Feeds[0];
                else
                    return feed;
            }
            set
            {
                feed = value;
            }
        }

        [JsonProperty("feeds")]
        public List<Entity> Feeds { get; set; }

        [JsonProperty("firstName")]
        public string FirstName { get; set; }

        [JsonProperty("image")]
        public string Image { get; set; }

        [JsonProperty("lastName")]
        public string LastName { get; set; }

        [JsonProperty("location")]
        public string Location { get; set; }

        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("phone")]
        public string Phone { get; set; }

        [JsonProperty("text")]
        public string Text { get; set; }

        [JsonProperty("title")]
        public string Title { get; set; }

        [JsonProperty("type")]
        public string Type { get; set; }

        [JsonProperty("url")]
        public string Url { get; set; }

        public bool IsMe(Entity other)
        {
            return other.Url == this.Url;
        }

    }

}
